package com.zzty.txj.controller;

import com.zzty.txj.entity.Location;
import com.zzty.txj.service.LocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/location")
public class LocationController {
    @Autowired
    LocationService locationServiceImpl ;

    @ResponseBody
    @RequestMapping(value="/insertLocation", method=RequestMethod.POST)
    public Integer insertLocation(Location location) {

        Integer count=locationServiceImpl.insertLocation(location);

        return count;
    }

    @ResponseBody
    @RequestMapping(value="/getLocations")
    public List<Location> getLocations() {
        List<Location> locations=new ArrayList<>();
        locations=locationServiceImpl.getLocations();
        return locations;
    }
    @ResponseBody
    @RequestMapping(value="/deleteLocation", method=RequestMethod.POST)
    public Integer deleteLocation(Location location) {

        Integer count=locationServiceImpl.deleteLocation(location);

        return count;
    }


}
